﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;

namespace Fuxi
{
    public partial class FuxiType
    {
        void MakeTurnDecision()
        {
            outs = HandEvaluator.GetNumberOuts(H.MyPocket, F.Board);
            drawing = (drawing || outs > 10);
            switch (strategy)
            {
                case StrategyType.Basic:
                    if (winOdds > 0.92 ||
                        winOdds > 0.85 && NumFuxiRaised(G.Turn) == 0 ||
                        H.HavePosition && NumOppRaised(G.Turn) == 0 && winOdds > 0.66 ||
                        !H.HavePosition && NumOppRaised(G.Turn) == 0 && winOdds > 0.75
                        )
                    {
                        ExecuteRaise();
                    }
                    else if (winOdds > 0.60 || drawing)
                    {
                        ExecuteCall();
                    }
                    else
                    {
                        ExecuteCheck();
                    }
                    break;
                case StrategyType.Trap:
                    if ( !(!H.HavePosition && NumOppRaised(G.Turn) == 0 && OppSbRaiseRate(G.Turn) > 0.6) &&
                        (winOdds > 0.92 ||
                        winOdds > 0.8 && NumFuxiRaised(G.Turn) == 0 ||
                        H.HavePosition && NumOppRaised(G.Turn) == 0 && winOdds > 0.66 ||
                        !H.HavePosition && NumOppRaised(G.Turn) == 0 && winOdds > 0.75
                        )
                        )
                    {
                        ExecuteRaise();
                    }
                    else if (winOdds > ImpliedPotOdds * 1.2 || drawing)
                    {
                        ExecuteCall();
                    }
                    else
                    {
                        ExecuteCheck();
                    }
                    break;
                case StrategyType.Jackel:
                       if (winOdds > 0.92 ||
                        winOdds > 0.8 && NumFuxiRaised(G.Turn) == 0 ||
                        H.HavePosition && NumOppRaised(G.Turn) == 0 && winOdds > 0.66 ||
                        !H.HavePosition && NumOppRaised(G.Turn) == 0 && winOdds > 0.75
                        )
                    {
                        ExecuteRaise();
                    }
                    else if (winOdds > 0.66 || outs > 10 || drawing)
                    {
                        ExecuteCall();
                    }
                    else
                    {
                        ExecuteCheck();
                    }
                    break;
                default:
                    break;
            }

        }
    }
}
